package com.gupao.gupaoeduvippattern.javaBase.day02;

import org.junit.jupiter.api.Test;

import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;

public class Demo01 {


    @Test
    public void test5(){
        Map<String, String> map = new HashMap<>();
        map.put("1", "111");
        map.put("2", null);
        System.out.println(map);
    }


    @Test
    public void test4(){
        double d1 = 0.0;
        if(1+2 == 0){
            System.out.println("d1为0");
        }else{
            System.out.println("d1");
        }
    }
    
    
    @Test
    public void test3(){
        DecimalFormat df = new DecimalFormat("0.00");
        double d = 0.3456;
        String format = df.format(d);
        System.out.println(format);
    }
    

    @Test
    public void test2(){
        String str = "good";
        List<String> list = new ArrayList<>();
        list.add("a");
        formatData(str, list);
        System.out.println(str+","+list);
    }

    private void formatData(String str, List<String> list){
        str = "新的哦";
        list.add("Java");
    }

    @Test
    public void test1(){
        List<Map<String, Object>> list = new ArrayList<>();
        for(int i=0; i<3; i++){
            Map<String, Object> map = new HashMap<>();
            map.put("keyA"+i, "valueA"+i);
            map.put("keyAA"+i, "valueAA"+i);
            Set<Map.Entry<String, Object>> entries = map.entrySet();
            for(Map.Entry<String, Object> entry : entries){
                System.out.println(entry.getKey()+","+entry.getValue());
            }
            list.add(map);
        }
        System.out.println(list);


        //使用jdk8的流
//        list.stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,(v1,v2)->v2));

    }

}
